package components;

public class PrePostCond {

	private final Variable var;
	private final int value;
	private final int effect;
	
	
	
	public PrePostCond(Variable v,int x,int y) throws Exception{
		var=v;
		value=x;
		effect=y;
		if (x>var.getDomain() || y>var.getDomain())
			throw new Exception("illegal prepost cond value or effect cant be bigger then domain");
	}
	
	
	
	public int getValue() {
		return value;
	}

	public int getEffect() {
		return effect;
	}
	
	
	public boolean confirm(){
		return (var.getState()==value ||value==-1);
	}
	
	public void start() throws Exception{
		var.setState(effect);
	}
/**
 * output string
 * @return
 */
	public String toString2() {
		return "0\n"+var.getIndex()+" "+value+" "+effect+"\n";
	}
/**
 * getter
 * @return
 */
	public Variable getVar() {
		return var;
	}
	
	
}


